﻿<phone:PhoneApplicationPage 
    x:Class="PhotoMap.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
    xmlns:mCore="clr-namespace:Microsoft.Phone.Controls.Maps.Core;assembly=Microsoft.Phone.Controls.Maps"
    xmlns:local="clr-namespace:PhotoMap"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    Loaded="PhoneApplicationPage_Loaded"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="PushpinStyle" TargetType="my:Pushpin">
            <Setter Property="BorderBrush" Value="#FFF4F4F5" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Canvas Height="0"
	                        RenderTransformOrigin="0.5,0.5"
	                        Width="0">
                            <Canvas RenderTransformOrigin="0.5,0.5"
                        		Height="1"
                        		Width="1">
                                <Canvas.RenderTransform>
                                    <ScaleTransform ScaleX="2" ScaleY="2"/>
                                </Canvas.RenderTransform>
                                <Path Data="M22.5,1 C34.374123,1 44,10.625878 44,22.5 C44,31.034525 39.027256,38.407604 31.821138,41.879868 L31.359026,42.095631 L22.702744,60.864998 L13.900847,42.209641 L13.651964,42.100761 C6.1912994,38.727623 0.99999976,31.220058 1,22.5 C0.99999976,10.625878 10.625878,1 22.5,1 z"
                        			Fill="{TemplateBinding BorderBrush}"
                        			Height="61.865"
                        			Stretch="Fill"
                        			Stroke="Transparent"
                        			StrokeThickness="0"
                        			StrokeLineJoin="Miter"
                        			UseLayoutRounding="False"
                        			Width="45"
                        			RenderTransformOrigin="0.5,0.5"
                        			Canvas.Left="-2.703"
                        			Canvas.Top="-7.187" >
                                    <Path.RenderTransform>
                                        <CompositeTransform TranslateX="-20" TranslateY="-55"/>

                                    </Path.RenderTransform>
                                </Path>
                            </Canvas>
                            <ContentPresenter Width="84" HorizontalAlignment="Center" VerticalAlignment="Center"
                        		Height="84"
                        		RenderTransformOrigin="0.5,0.5"
                        		Canvas.Top="-70" Canvas.Left="-25">
                                <ContentPresenter.RenderTransform>
                                    <CompositeTransform TranslateX="-18"
                        				TranslateY="-54"/>
                                </ContentPresenter.RenderTransform>
                                <ContentPresenter.Clip>
                                    <EllipseGeometry Center="42,43" RadiusX="43" RadiusY="42"/>
                                </ContentPresenter.Clip>
                            </ContentPresenter>
                            <Ellipse Height="45" Width="66" RenderTransformOrigin="0.5,0.5" Canvas.Left="4" Canvas.Top="-46" 
							StrokeThickness="0">
                                <Ellipse.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                        <GradientStop Color="Transparent" Offset="1"/>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                                <Ellipse.RenderTransform>
                                    <CompositeTransform TranslateX="-38" TranslateY="-76"/>
                                </Ellipse.RenderTransform>
                            </Ellipse>
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="SelfPushpinStyle" TargetType="my:Pushpin">
            <Setter Property="BorderBrush" Value="#FFF4F4F5" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Canvas Height="0" Background="Yellow"
	                        RenderTransformOrigin="0.5,0.5"
	                        Width="0">
                            <Canvas RenderTransformOrigin="0.5,0.5"
                        		Height="1"
                        		Width="1">
                                <Canvas.RenderTransform>
                                    <ScaleTransform ScaleX="2" ScaleY="2"/>
                                </Canvas.RenderTransform>
                                <Path Data="M22.5,1 C34.374123,1 44,10.625878 44,22.5 C44,31.034525 39.027256,38.407604 31.821138,41.879868 L31.359026,42.095631 L22.702744,60.864998 L13.900847,42.209641 L13.651964,42.100761 C6.1912994,38.727623 0.99999976,31.220058 1,22.5 C0.99999976,10.625878 10.625878,1 22.5,1 z"
                        			Fill="{TemplateBinding BorderBrush}"
                        			Height="61.865"
                        			Stretch="Fill"
                        			Stroke="Black"
                        			StrokeThickness="0"
                        			StrokeLineJoin="Miter"
                        			UseLayoutRounding="False"
                        			Width="45"
                        			RenderTransformOrigin="0.5,0.5"
                        			Canvas.Left="-2.703"
                        			Canvas.Top="-7.187" >
                                    <Path.RenderTransform>
                                        <CompositeTransform TranslateX="-20" TranslateY="-55"/>

                                    </Path.RenderTransform>
                                </Path>
                            </Canvas>
                            <ContentPresenter Width="84" HorizontalAlignment="Center" VerticalAlignment="Center"
                        		Height="84"
                        		RenderTransformOrigin="0.5,0.5"
                        		Canvas.Top="-70" Canvas.Left="-25">
                                <ContentPresenter.RenderTransform>
                                    <CompositeTransform TranslateX="-18"
                        				TranslateY="-54"/>
                                </ContentPresenter.RenderTransform>
                                <ContentPresenter.Clip>
                                    <EllipseGeometry Center="42,43" RadiusX="43" RadiusY="42"/>
                                </ContentPresenter.Clip>
                            </ContentPresenter>
                            <Ellipse Height="45" Width="66" RenderTransformOrigin="0.5,0.5" Canvas.Left="4" Canvas.Top="-46" 
							StrokeThickness="0">
                                <Ellipse.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                        <GradientStop Color="Transparent" Offset="1"/>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                                <Ellipse.RenderTransform>
                                    <CompositeTransform TranslateX="-38" TranslateY="-76"/>
                                </Ellipse.RenderTransform>
                            </Ellipse>
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- #Styles -->
        <Style x:Key="ButtonZoomInStyle" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
            <Setter Property="Padding" Value="10,3,10,5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent" Width="48" Height="48">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image1">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="image" d:IsOptimized="True"/>
                                            <DoubleAnimation Duration="0" To="0.4" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="image1" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused"/>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ButtonBackground">
                                <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Center" VerticalAlignment="Center">
                                    <Grid Height="48" Width="48" HorizontalAlignment="Center" VerticalAlignment="Center">
                                        <Image x:Name="image" Source="/Images/Zoom/ZoomIn_Black.png" Stretch="Fill" Visibility="Collapsed"/>
                                        <Image x:Name="image1" Source="/Images/Zoom/ZoomIn_White.png" Stretch="Fill"/>
                                    </Grid>
                                </ContentControl>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ButtonZoomOutStyle" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
            <Setter Property="Padding" Value="10,3,10,5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent" Width="48" Height="48">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="image1">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation Duration="0" To="0.4" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="image1" d:IsOptimized="True"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused"/>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ButtonBackground">
                                <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="Center" VerticalAlignment="Center">
                                    <Grid Height="48" Width="48" HorizontalAlignment="Center" VerticalAlignment="Center">
                                        <Image x:Name="image1" Source="/Images/Zoom/ZoomOut_White.png" Stretch="Fill"/>
                                        <Image x:Name="image" Source="/Images/Zoom/ZoomOut_Black.png" Stretch="Fill" Visibility="Collapsed"/>
                                    </Grid>
                                </ContentControl>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <my:Map x:Name="myMap" 
                    ZoomLevel="4"
                Center="39.913686, 116.399605"
                    CopyrightVisibility="Collapsed"
                    LogoVisibility="Collapsed"
                    ZoomBarVisibility="Collapsed"
                    d:LayoutOverrides="Width" ScaleVisibility="Visible" CredentialsProvider="AgyuXoy2cMUO2BXbN0agH4EGeFk_vlRESLeypiyD4s2qYljtUstzzaZ0RqK0G_Ye">
            <my:Map.Mode>
                <mCore:MercatorMode></mCore:MercatorMode>
            </my:Map.Mode>

            <my:Map.Children>
                <!--<my:Pushpin x:Name="test" Background="Blue" Style="{StaticResource PushpinStyle}">
                    <Image Source="\Images\test.jpg" Stretch="Fill"/>
                </my:Pushpin>-->

                <my:MapTileLayer d:IsHidden="True">
                    <my:MapTileLayer.TileSources>
                        <local:NokiaMapsRoadTileSource></local:NokiaMapsRoadTileSource>
                    </my:MapTileLayer.TileSources>
                </my:MapTileLayer>
                <my:MapItemsControl ItemsSource="{Binding Pushpins}" >
                    <my:MapItemsControl.ItemTemplate>
                        <DataTemplate>
                            <my:Pushpin Location="{Binding Location}" Content="{Binding Path=PlaceName}" />
                        </DataTemplate>
                    </my:MapItemsControl.ItemTemplate>
                </my:MapItemsControl>

                <Border Background="#99000000" 
                        HorizontalAlignment="Left" VerticalAlignment="Top"
                        CornerRadius="35"
                        Height="152" Width="70" Margin="8,180,0,0">

                    <StackPanel>
                        <Button x:Name="ButtonZoomIn"
                            Style="{StaticResource ButtonZoomInStyle}"
                            Height="56" Width="56" Margin="0,10"
                            Click="ButtonZoomIn_Click" />

                        <Button x:Name="ButtonZoomOut"
                            Style="{StaticResource ButtonZoomOutStyle}"
                            Height="56" Width="56" Margin="0,10"
                            Click="ButtonZoomOut_Click" />
                    </StackPanel>
                </Border>

            </my:Map.Children>
        </my:Map>

        <StackPanel x:Name="loadingPanel" VerticalAlignment="Top" Visibility="Collapsed"
                    Background="#66000000" Height="45">
            <TextBlock Text="正在定位" TextAlignment="Center"/>
            <toolkit:PerformanceProgressBar VerticalAlignment="Top" Margin="0,5,0,0"
                                            IsIndeterminate="True" />
        </StackPanel>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_Location.png" Text="定位" Click="locatePhotoApplicationBarIconButton_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_add.png" Text="打开图片" Click="addPhotoApplicationBarIconButton_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_option.png" Text="设置" Click="optionPhotoApplicationBarIconButton_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="关于" Click="aboutApplicationBarMenuItem_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
